package crazy.serializable;

import java.io.FileOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;

public class WriteTeacher
{
	public static void main(String[] args)
	{
		ObjectOutputStream oos = null;
		try
		{
			oos = new ObjectOutputStream(new FileOutputStream("c:\\a.txt"));
			Person per = new Person("sun wukong", 500);
			Teacher t1 = new Teacher("tangsen", per);
			Teacher t2 = new Teacher("puti", per);
			
			oos.writeObject(t1);
			oos.writeObject(t2);
			oos.writeObject(per);
			oos.writeObject(t2);
		}
		catch (Exception e)
		{
			// TODO: handle exception
			e.printStackTrace();
		}
		finally
		{
			try
			{
				if (oos != null)
				{
					oos.close();
				}
			}
			catch (Exception e2)
			{
				// TODO: handle exception
				e2.printStackTrace();
			}
		}
	}
}
